import request from '@/config/axios'

// 分类 VO
export interface CategoryVO {
  id: number | undefined // 唯一编号
  parentId: string | undefined // 上级编号
  name: string | undefined // 名称
  iconUrl: string | undefined // 图标
  status: number | undefined // 状态
  sort: number | undefined // 排序
}

// 分类 API
export const CategoryApi = {
  // 查询分类列表
  getCategoryList: async (module: string, identity: string, params: any) => {
    return await request.get({
      url: `/${module}/${identity}-category/list`,
      params
    })
  },
  // 查询分类列表
  getCategorySimpleList: async (module: string, identity: string, params: any) => {
    return await request.get({
      url: `/${module}/${identity}-category/simple-list`,
      params
    })
  },

  // 查询分类详情
  getCategory: async (module: string, identity: string, id: number) => {
    return await request.get({
      url: `/${module}/${identity}-category/get?id=` + id
    })
  },

  // 新增分类
  createCategory: async (module: string, identity: string, data: CategoryVO) => {
    return await request.post({
      url: `/${module}/${identity}-category/create`,
      data
    })
  },

  // 修改分类
  updateCategory: async (module: string, identity: string, data: CategoryVO) => {
    return await request.post({
      url: `/${module}/${identity}-category/update`,
      data
    })
  },

  // 删除分类
  deleteCategory: async (module: string, identity: string, id: number) => {
    return await request.get({
      url: `/${module}/${identity}-category/delete?id=` + id
    })
  },

  // 导出分类 Excel
  exportCategory: async (module: string, identity: string, params) => {
    return await request.download({
      url: `/${module}/${identity}-category/export-excel`,
      params
    })
  }
}
